package main

import (
	"fmt"
	"time"
)

func water() <-chan string {
	out := make(chan string)
	go func() {
		time.Sleep(time.Second * 1)
		out <- "开水"
	}()
	return out
}

func vegetable() <-chan string {
	out := make(chan string)
	go func() {
		time.Sleep(time.Second * 3)
		out <- "炒青菜"
	}()
	return out
}

func rice() <-chan string {
	out := make(chan string)
	go func() {
		time.Sleep(time.Second * 6)
		out <- "米饭"
	}()
	return out
}

func main() {
	w := water()
	v := vegetable()
	r := rice()
	<-w
	fmt.Println("水开了，倒水...")
	<-v
	fmt.Println("菜好了，上菜...")
	<-r
	fmt.Println("饭好了，盛饭...")
	fmt.Println("开动。")
}
